﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UEmpPay.ascx.cs" Inherits="PayRoller.Include.UEmpPay" %>
<%@ Register src="../UControls/TXTFormatDate.ascx" tagname="TXTFormatDate" tagprefix="uc1" %>
<script language="javascript" type="text/javascript">
        function Check1() {
            var vdlPayment = document.getElementById("<%=dlPayment.ClientID %>");
            var vtxtAmount = document.getElementById("<%=txtAmount.ClientID %>");

            if (vdlPayment.value.length == 0) {
                alert("Field 'Payment' is not valid!");
                vdlPayment.focus();
                return false;
            }
            if (vtxtAmount.value.length == 0) {
                alert("Field 'Change amount to' is not valid!");
                vtxtAmount.focus();
                return false;
            }
            if (!chknum(vtxtAmount.value)) {
                alert(" Field 'Change amount to' is not valid!");
                vtxtAmount.focus();
                return false;
            }

            return true;
        }

        function Check2() {
            first= Check2_Tip();
            if (first == false) {
                return false;
            }

            second = Check2_Valide();
            if (second == false) {
                return false;
            }

            return true;
        }

        function Check2_Tip() {
           return confirm("Do you confirm the payment?");
        }

        function Check2_Valide() {
            var vtxtPaymentDate = document.getElementById("<%=txtPaymentDate %>");
            var vtxtPaymentAmount = document.getElementById("<%=txtPaymentAmount %>");
            var vdlAccount = document.getElementById("<%=dlAccount %>");

            if (vtxtPaymentDate.value.length == 0) {
                alert("Field 'Payment Date' is not valid!");
                vtxtPaymentDate.focus();
                return false;
            }
            if (!chkdate2(vtxtPaymentDate.value)) {
                alert(" Field 'Payment Date' is not valid!");
                vtxtPaymentDate.focus();
                return false;
            }
            if (vtxtPaymentAmount.value.length == 0) {
                alert("Field 'Payment Amount' is not valid!");
                vtxtPaymentAmount.focus();
                return false;
            }
            if (!chknum(vtxtPaymentAmount.value)) {
                alert(" Field 'Payment Amount' is not valid!");
                vtxtPaymentAmount.focus();
                return false;
            }
            if (vdlAccount.value.length == 0) {
                alert("Field 'Select from Account' is not valid!");
                vdlAccount.focus();
                return false;
            }

            return true;
        }

        function Check3() {
            var vdlPayment2 = document.getElementById("<%= dlPayment2 %>");

            if (vdlPayment2.value.length == 0) {
                alert("Field 'Payment' is not valid!");
                vdlPayment2.focus();
                return false;
            }

            return confirm('Are you sure you would like to delete this payment?');
        }

        function Check4() {
            var vtxtBankName = document.getElementById("<%= txtBankName %>");
            var vtxtBranch = document.getElementById("<%= txtBranch %>");
            var vtxtAccountName = document.getElementById("<%= txtAccountName %>");

            if (vtxtBankName.value.length == 0) {
                alert("Field 'Bank Name' is not valid!");
                vtxtBankName.focus();
                return false;
            }
            if (vtxtBranch.value.length == 0) {
                alert("Field 'Branch' is not valid!");
                vtxtBranch.focus();
                return false;
            }
            if (vtxtAccountName.value.length == 0) {
                alert("Field 'Account Name' is not valid!");
                vtxtAccountName.focus();
                return false;
            }

            return true;
        }
    </script>

    <table width="99%" align="center" border="0" cellspacing="0" cellpadding="0" class="NormalText">
        <tr>
            <td height="40" colspan="2" class="HeadText">
                Employee Details
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <table cellspacing="0" cellpadding="0" width="90%" border="0">
                    <tbody>
                        <tr>
                            <td height="22">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td width="25%" height="22">
                                            <div align="left">
                                                Employee Name:</div>
                                        </td>
                                        <td>
                                            <div align="left">
                                                <%=EmpName%></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="22">
                                            <div align="left">
                                                Our Ref:</div>
                                        </td>
                                        <td>
                                            <div align="left">
                                                <%=Sid%></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="22">
                                            <div align="left">
                                                Employee ID:</div>
                                        </td>
                                        <td>
                                            <div align="left">
                                                <%=OrgEmpSid%></div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td height="15">
                            </td>
                        </tr>
                        <tr>
                            <td height="22">
                                <div align="left">
                                    Please select the type of change you would like to make to this employee&rsquo;s
                                    schedule:</div>
                            </td>
                        </tr>
                        <tr>
                            <td align="left">
                                <asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
                                    AutoPostBack="True">
                                    <asp:ListItem Value="0">Change this employee&rsquo;s debit amount</asp:ListItem>
                                    <asp:ListItem Value="1">Add an additional payment</asp:ListItem>
                                    <asp:ListItem Value="2">Delete a scheduled payment</asp:ListItem>
                                    <asp:ListItem Value="3">Add Nominated Bank</asp:ListItem>
                                    <asp:ListItem Value="5">Added Nominated Bank</asp:ListItem>
                                    <asp:ListItem Value="4">Change this employee&rsquo;s status</asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE1" cellspacing="0" cellpadding="0" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td style="height: 22px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22" align="left">
                                                Please select the payment that you wish to change the amount of:
                                                <asp:DropDownList ID="dlPayment" runat="server" >
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 22px" align="left">
                                                Change amount to: $
                                                <asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22" align="left">
                                                <asp:CheckBox ID="cbPayment" runat="server"></asp:CheckBox>Also apply this change
                                                to all future payments after the selected payment.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" height="25">
                                                <asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Submit Update"
                                                    CssClass="submitBtn"></asp:Button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE2" cellspacing="0" cellpadding="0" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td colspan="4" height="22">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 24px" width="20%">
                                                <div align="left">
                                                    Payment Date:</div>
                                            </td>
                                            <td style="height: 24px" align="left">
                                                <uc1:TXTFormatDate ID="txtPaymentDate" Width="80"  runat="server" />
                                            </td>
                                            <td style="height: 24px" width="20%">
                                                <div align="left">
                                                    Payment Amount:</div>
                                            </td>
                                            <td style="height: 24px" align="left">
                                                <asp:TextBox ID="txtPaymentAmount" runat="server" Width="50px"></asp:TextBox>
                                                <asp:Literal ID="litAmountTip" runat="server"></asp:Literal>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td  height="22" align="left">
                                                Select from Account:
                                             </td>
                                             <td align="left"><asp:DropDownList ID="dlAccount" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                            <td  align="left">
                                                Reference Info:
                                             </td>
                                             <td align="left">
                                                 <asp:TextBox ID="txtReferenceInfo" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="line-height: 130%" colspan="4">
                                                <div align="left">
                                                    Please note: If your new payment date fall on a public holiday the payment date
                                                    will be shifted to the next available working day.
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="4" height="25">
                                                <asp:Button ID="Button2" OnClick="Button2_Click" runat="server" Text="Submit Update"
                                                    CssClass="submitBtn"></asp:Button>
                                                &nbsp;
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE3" cellspacing="0" cellpadding="0" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td height="22">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22" align="left">
                                                Delete payment
                                                <asp:DropDownList ID="dlPayment2" runat="server" >
                                                </asp:DropDownList>
                                                from this employee&rsquo;s payment schedule.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" height="25">
                                                <asp:Button ID="Button3" OnClick="Button3_Click" runat="server" Text="Submit Update"
                                                    CssClass="submitBtn"></asp:Button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE4" cellspacing="1" cellpadding="1" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td colspan="4" height="22">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px" width="20%">
                                                <div align="left">
                                                    Bank Name:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtBankName" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px" width="20%">
                                                <div align="left">
                                                    Branch:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtBranch" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    Account Name:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtAccountName" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                <div align="left">
                                                    BSB:</div>
                                            </td>
                                            <td>
                                                <div align="left">
                                                    <asp:TextBox ID="txtBsb" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    Account Number:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtAccountNum" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 24px">
                                                <div align="left">
                                                    Reference:</div>
                                            </td>
                                            <td style="height: 24px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtPayReference" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" height="22">
                                                <asp:Button ID="Button4" OnClick="Button4_Click" runat="server" Text="Submit Update"
                                                    CssClass="submitBtn"></asp:Button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE6" cellspacing="1" cellpadding="1" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td colspan="4" height="22">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
                                                    <tr>
                                                        <td height="22" bgcolor="#CCCCCC">
                                                            <strong>Bank Name</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC">
                                                            <strong>Branch</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC">
                                                            <strong>Account Name</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC">
                                                            <strong>BSB</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC">
                                                            <strong>Account Number</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC">
                                                            <strong>Reference</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC" align="center">
                                                            <strong>Edit</strong>
                                                        </td>
                                                        <td bgcolor="#CCCCCC" align="center">
                                                            <strong>Delete</strong>
                                                        </td>
                                                    </tr>
                                                    <%		 
                                                        for (int i = 0; i < dtBankList.Rows.Count; i++)
                                                        {
                                                            string BankSid = dtBankList.Rows[i]["Sid"].ToString();
                                                            string BankName = dtBankList.Rows[i]["BankName"].ToString();
                                                            string Branch = dtBankList.Rows[i]["Branch"].ToString();
                                                            string AccountName = dtBankList.Rows[i]["AccountName"].ToString();
                                                            string AccountNum = dtBankList.Rows[i]["AccountNum"].ToString();
                                                            string Bsb = dtBankList.Rows[i]["Bsb"].ToString();
                                                            string PayReference = dtBankList.Rows[i]["PayReference"].ToString();
                                                    %>
                                                    <tr>
                                                        <td height="22" bgcolor="#ffffff">
                                                            <%=BankName%>
                                                        </td>
                                                        <td bgcolor="#ffffff">
                                                            <%=Branch%>
                                                        </td>
                                                        <td bgcolor="#ffffff">
                                                            <%=AccountName%>
                                                        </td>
                                                        <td bgcolor="#ffffff">
                                                            <%=Bsb%>
                                                        </td>
                                                        <td bgcolor="#ffffff">
                                                            <%=AccountNum%>
                                                        </td>
                                                        <td bgcolor="#ffffff">
                                                            <%=PayReference%>
                                                        </td>
                                                        <td bgcolor="#ffffff" align="center">
                                                            <a href="EmpPay.aspx?OrgSid=<%=OrgSid%>&EmpSid=<%=Sid%>&BankSid=<%=BankSid%>">Edit</a>
                                                        </td>
                                                        <td bgcolor="#ffffff" align="center">
                                                            <a href="EmpPayDel.aspx?EmpSid=<%=Sid%>&BankSid=<%=BankSid%>" onclick="return confirm('really delete it?')">
                                                                Delete</a>
                                                        </td>
                                                    </tr>
                                                    <% }%>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px" width="20%">
                                                <div align="left">
                                                    Bank Name:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtBankName2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px" width="20%">
                                                <div align="left">
                                                    Branch:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtBranch2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    Account Name:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtAccountName2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td height="22">
                                                <div align="left">
                                                    BSB:</div>
                                            </td>
                                            <td>
                                                <div align="left">
                                                    <asp:TextBox ID="txtBsb2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    Account Number:</div>
                                            </td>
                                            <td style="height: 26px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtAccountNum2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="height: 24px">
                                                <div align="left">
                                                    Reference:</div>
                                            </td>
                                            <td style="height: 24px">
                                                <div align="left">
                                                    <asp:TextBox ID="txtPayReference2" runat="server" Width="200px"></asp:TextBox>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" style="height: 22px">
                                                <asp:Button ID="Button6" runat="server" Text="Submit Update" CssClass="submitBtn"
                                                    OnClick="Button6_Click"></asp:Button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="TABLE5" cellspacing="0" cellpadding="0" width="100%" border="0" runat="server">
                                    <tbody>
                                        <tr>
                                            <td colspan="4" height="22">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="50%" height="22" align="left">
                                                Current Status:<%=EmpStatus%>
                                            </td>
                                            <td align="left">
                                                Change To:
                                                <asp:DropDownList ID="dlStatus" runat="server">
                                                    <asp:ListItem Value="1">Active</asp:ListItem>
                                                    <asp:ListItem Value="0">Terminated</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="4" height="22">
                                                <asp:Button ID="Button5" OnClick="Button5_Click" runat="server" Text="Submit Update"
                                                    CssClass="submitBtn"></asp:Button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td height="26" colspan="2" align="center">
                <a href="EmpDetail.aspx?OrgSid=<%=OrgSid%>&Sid=<%=Sid%>" runat="server" id="btnReturn">Return</a>
            </td>
        </tr>
        <tr>
            <td height="22" colspan="2">
                <asp:Label ID="lblTip" runat="server"></asp:Label>&nbsp;</td>
        </tr>
    </table>
   